package com.trsvax.gwthello.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Element;
import com.google.gwt.i18n.client.Dictionary;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.RootPanel;
import com.trsvax.gwthello.client.gwtui.widgets.CategoryPanelWidget;
import com.trsvax.gwthello.client.gwtui.widgets.CheckBoxWidget;
import com.trsvax.gwthello.client.gwtui.widgets.DatePickerWidget;
import com.trsvax.gwthello.client.gwtui.widgets.DisclosurePanelWidget;
import com.trsvax.gwthello.client.gwtui.widgets.GaugeWidget;
import com.trsvax.gwthello.client.gwtui.widgets.LineChartWidget;
import com.trsvax.gwthello.client.gwtui.widgets.MenuWidget;
import com.trsvax.gwthello.client.gwtui.widgets.PieChartWidget;
import com.trsvax.gwthello.client.gwtui.widgets.SlideShowWidget;
import com.trsvax.gwthello.client.gwtui.widgets.StackPanelWidget;
import com.trsvax.gwthello.client.gwtui.widgets.TabPanelWidget;
import com.trsvax.gwthello.client.gwtui.widgets.TimeLineWidget;
import com.trsvax.gwthello.client.widget.ButtonWidget;

public class GWTUI extends GWTTapestry implements EntryPoint {

	@Override
	public Composite widgetFactory(String id) {
		Dictionary dictionary = Dictionary.getDictionary(id);
		Element element = RootPanel.get(id).getElement();
		String type = dictionary.get("type");

		if ("TabPanelComponent".equals(type))
			return new TabPanelWidget(element, dictionary);

		if ("StackPanel".equals(type))
			return new StackPanelWidget(id, dictionary);

		if ("DatePicker".equals(type))
			return new DatePickerWidget(id, dictionary);

		if ("Menu".equals(type))
			return new MenuWidget(element, dictionary);

		if ("Button".equals(type))
			return new ButtonWidget(id, dictionary);

		if ("DisclosurePanel".equals(type))
			return new DisclosurePanelWidget(id, dictionary);

		if ("CheckBox".equals(type))
			return new CheckBoxWidget(id, dictionary);

		if ("SlideShow".equals(type))
			return new SlideShowWidget(id, dictionary);

		if ("CategoryPanel".equals(type))
			return new CategoryPanelWidget(element, dictionary);

		if ("PieChart".equals(type))
			return new PieChartWidget(element, dictionary);

		if ("TimeLine".equals(type))
			return new TimeLineWidget(element, dictionary);

		if ("LineChart".equals(type))
			return new LineChartWidget(element, dictionary);

		if ("Gauge".equals(type))
			return new GaugeWidget(element, dictionary);

		return null;

	}
}
